<?php
/*
	Copyright (C) 2008 - 2012 Inanta Martsanto
	Inanta Martsanto (inanta@inationsoft.com)

	This file is part of NewStep Framework.

	NewStep Framework is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	NewStep Framework is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with NewStep Framework.  If not, see <http://www.gnu.org/licenses/>.
*/

namespace Inationsoft\NS\Core;

use Inationsoft\NS\SingletonObject;

/**
 *Handle configuration values from multiplle file in configuration folder or runtime configuration
 *
 *@author Inanta Martsanto <inanta@inationsoft.com>
 */
class Config extends SingletonObject {
	private $_group;

	/**
	*Load configuration file by name in configuration folder
	*
	*/
	function load($name) {
		require(NS_SYSTEM_PATH . '/' . $this->ConfigFolder . '/' . $name . '.inc.php');
		$this->createProperties(array($name => ${$name}), true);
	}

	/**
	*Bind value to class property
	*
	*/
	function bind(&$value) {
		$this->bindProperties($value);
	}

	/**
	*Add new configuration on run time
	*
	*/
	function add($value) {
		$this->createProperties($value, true);
	}

	/**
	*Create or retrieve object instance
	*
	*/
	static function getInstance() { return self::createInstance(__CLASS__); }
}
?>
